package examples 
{
	import com.sociodox.theminer.TheMiner;
	import entities.PlatformBoy;
	import pure.engine.world.WorldBody;
	
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.utils.*;
	
	import pure.debug.*;
	import pure.engine.*;
	import pure.engine.world.monitor.*;
	import pure.engine.renderer.*;
	import pure.engine.status.*;
	import pure.engine.status.motion.*;
	import pure.engine.world.WorldManager;
	import pure.ui.Button;
	import pure.utils.DesU;
	
	import sections.SectionData;
	
	/**
	 * @author pure
	 */
[SWF(width="960",height="580",backgroundColor="0xeeeeee",frameRate="60")]
public class PlatformDemo extends Sprite 
{

	public function PlatformDemo() 
	{
		this.addEventListener(Event.ADDED_TO_STAGE, init);
	}
	
	private function init(e:Event):void
	{
		this.removeEventListener(Event.ADDED_TO_STAGE, init);
		
		var _mochiads_game_id:String = "b0fd1461aef7089f";
		
		stage.quality = 'high';
		stage.align = 'TL';
		stage.scaleMode = 'noScale';
		
		addChild(new TheMiner());
		
		// 启动
		Despair.startup(this.stage);

		// 注册片段
		Despair.registerSections(SectionData.data);

		// 注册实体
		Despair.registerEntities(PlatformBoy);

		// 注册世界Body
		var body:WorldBody = Despair.registerWorldBody('p','id');
		body.configureMonitor(960, 480,0.9,0xff0000);
		body.show(0, 60);
		body.setWorld(new PlatformWorldB());
		
		// 'RESET'按钮
		var button:Button = new Button(50, 20, new Point(60, 25));
		button.label = 'RESET';
		button.setObserverClick(function():void 
		{
			//Despair.setWorld(new Box2DWorld());
			body.setWorld(new PlatformWorldB());
		})
		addChild(button);
		
		// 'MONITOR-2'按钮
		//var button2:Button = new Button(150, 20, new Point(80, 25));
		//button2.label = 'MONITOR-2';
		//button2.setObserverClick(_makeMonitor2);
		//addChild(button2);
		
		var stats:StatsKai = new StatsKai();
		addChild(stats);
		stats.x = 890;
		
	}


	//protected function _makeMonitor2():void
	//{
		//if (_camera2)
		//{
			//_camera2.destroy();
			//_camera2 = null;
		//}
		//else
		//{
			//_camera2 = Despair.createMonitor(390, 440,'p',false, true, 0.8);
			//_camera2.moveInWorld(0, 600);
			//_camera2.x = 580;
			//_camera2.y = 70;
		//}
	//}

}

}
